import java.util.Scanner;


public class AG4 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int count = scan.nextInt();
		int[] o = new int[count];
		int[] dp = new int[count];
		while (--count >= 0) o[o.length - count - 1] = scan.nextInt();
		for (int i = 0; i < dp.length; i++) dp[i] = 1;
		//1 7 3 5 9 4 8
		//dp[i]表示当前已知在算以第i为结尾的子序列最优解，dp[j]表示当前第j个数的最优结果
		for (int i = 0; i < dp.length; i++) {
			for (int j = 0; j < i; j++) {
				if (o[i] > o[j]) dp[i] = Math.max(dp[j] + 1, dp[i]);

			}
		}
		int max = 0;
		for (int i = 0; i < dp.length; i++) max = Math.max(dp[i], max);
		System.out.println(max);
		scan.close();
	}

}
